/**
*	外贸预警
**/
app.controller('gWarningIndexCtrl', ['$scope', '$state', '$stateParams', '$http', 'utils',
  function($scope, $state, $stateParams, $http, utils) {
    // 页面数据
    $scope.warningData = {
      loading: false,
      listData: [],
      end: false,
      pageSize: 10,
      pageNo:1
    }

    $scope.stateParams = $stateParams;

    $scope.loadData = function (){
      if ($scope.warningData.loading) return;
      $scope.warningData.loading = true;

      utils.get('warningIndex', {
          type: $stateParams.type,
          random: Math.random(),
          pageSize: $scope.warningData.pageSize,
          pageNo: $scope.warningData.pageNo,
          keyWords: ''
      }).success(function (rs) {
        if (rs.data.length) {
          $scope.warningData.listData = $scope.warningData.listData.concat(rs.data);
        } else {
          $scope.warningData.end = true;
        }

        $scope.warningData.loading = false;

      });
    }

    // 加载更多
    $scope.loadmoreList = function () {
      if ($scope.warningData.end) return;
      $scope.warningData.pageNo++;
      $scope.loadData();
    }

    // 获取预警快报列表信息
    // utils.get('warningIndex', {
    //   type: $stateParams.type,
    //   keyWords: ''
    // }).success(function (rs) {
    //   $scope.warningData.listData = rs.data;
    //   $scope.warningData.loading = false;
    // });

    $scope.loadData();

  }
]);
